<template>
	<view class="page-body" :class="[app.setCStyle()]">
		<div class="times" >恭喜您中奖啦</div>
		<swiper :current="tabCurrentIndex" class="swiper-box" duration="300" @change="changeTab">
			<swiper-item class="tab-content" v-for="(tabItem,tabIndex) in navList" :key="tabIndex">
				<scroll-view class="hb100" scroll-y @scrolltolower="loadData">
					<!-- 空白页 -->
					<empty v-if="tabItem.loaded === true && tabItem.list.length === 0"></empty>
					<view v-for="(item,index) in tabItem.list" :key="index" class="p20 bg-white mb20 listtab">
						<view class="flex mt20">
							<image :src="baseUrl+item.photoprize" style="width:100rpx;height:100rpx;"></image>
							<view class="flex_bd ml20">
								<view class="flex">
									<view class="goods_name flex_bd">奖品名称:{{item.prize_name}}</view>
									<view class="ml10">
										<view>价值:<text class="fs22">￥</text>{{item.prizeprices}}</view>
									</view>
									  
								</view>
								<view class="flex">
									<view class="goods_name_sun flex_bd" v-if="item.wuliuid">快递公司：{{item.wuliuid}}</view>
								</view>
								<view class="flex">
									<view class="goods_name_sun flex_bd" v-if="item.danhao">单号：{{item.danhao}}</view>
								</view>
								<view class="flex">
									<view class="goods_name_sun flex_bd" v-if="item.fahuotime">发货时间：{{item.fahuotime}}</view>
								</view>
								<view class="flex">
									<view class="goods_name_sun flex_bd" v-if="item.bianma">兑换编码：{{item.bianma}}</view>
								</view>
								<view class="mt10 smll fixed">
									<view class="flex_bd color-cc fs26">数量:{{item.num}}</view>
									<view class="flex_bd color-cc fs26" v-if="item.status==1">已兑换</view>
									<view class="flex_bd color-cc fs26" v-else-if="item.status==0">未兑换</view>
									<button v-if="item.status == 0" class="fr action-btn recom" @click="app.goPage('/pages/member/center/changesend?id='+item.id)">去兑换</button> 
								</view>
							</view>
						</view>
					</view>
					 
				</scroll-view>
			</swiper-item>
		</swiper>
	</view>
</template>

<script>
	import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
	import empty from "@/components/empty";
	export default {
		components: {
			uniLoadMore,
			empty
		},
		data() {
			return {
				baseUrl: this.config.baseUrl,
				tabCurrentIndex: 0,
				param: {
					type: '',
					p: 0
				},
				navList: [{
						type: 'wait',
						text: '待评价',
						loadingType: 'more',
						list: [],
						p: 0
					},
					{
						type: 'finish',
						text: '已评价',
						loadingType: 'more',
						list: [],
						p: 0
					}
				],
			 
			};
		},
		onLoad(options) {
			this.app.isLogin(this);//强制登陆
			
			this.loadData();
		},
		methods: {
			//获取列表
			loadData(source) {
				//这里是将订单挂载到tab列表下
				let index = this.tabCurrentIndex;
				let navItem = this.navList[index];
				if (navItem.loadingType == 'nomore') {
					return;
				}
				if (source === 'tabChange' && navItem.loaded === true) {
					//tab切换只有第一次需要加载数据
					return;
				}
				if (navItem.loadingType === 'loading') {
					//防止重复加载
					return;
				}
				//navItem.p++;
				//this.param.type = navItem.type;
				//this.param.p = navItem.p;
				//navItem.loadingType = 'loading';
				this.$u.post('shop/api.Prize/getList', this.param).then(res => {
					//navItem.list = navItem.list.concat(res.data.list);
					navItem.list = res.data.list;
					//loaded新字段用于表示数据加载完毕，如果为空可以显示空白页
					//this.$set(navItem, 'loaded', true);
					//判断是否还有下一页，有是more  没有是nomore
					//navItem.loadingType = navItem.p == res.data.page_count ? 'nomore' : 'more';
				})
			},
	
			//swiper 切换
			changeTab(e) {
				this.tabCurrentIndex = e.target.current;
				this.loadData('tabChange');
			},
			//顶部tab点击
			tabClick(index) {
				this.tabCurrentIndex = index;
			},
			addAddress(type, item) {
				let from = this.from;
				uni.navigateTo({
					url: `/pages/member/center/changesend?from=${from}&type=${type}&id=item`
				})
			}
		},
	}
</script>

<style lang="scss">
	.page-body{
		background: url("/static/public/images/bg_bubbles2.jpg");
		background-size: 100% 100%;
		position: fixed;
		background-repeat:no-repeat;
		width: 100%;
		height: 100%;
		
		.times {
		  background: #FF781A;
		  text-align: center; 
		  width: 300px;
		  height: 55px;
		  line-height: 55px;
		  border-radius: 20px;
		  color: #fff;
		  margin: 0 auto;
		  margin-top: 180px; 
		  display: block; 
		  font-weight: 700;
		  font-size: 40rpx;
		}
		.listtab{
			width: 90%;
			margin: 0 auto;
			border-radius: 15px;
		}
		.goods_name_sun{
			display: block;
			    font-size: 15px;
			    color: #333;
			    line-height: 26px;
			    height: 26px;
			    overflow: hidden;
			    text-overflow: ellipsis;
			    display: -webkit-box;
			    -webkit-line-clamp: 2;
			    -webkit-box-orient: vertical;
		}
		
	}
	.swiper-box {
		height: calc(100% - 50px);
		margin-top: 20px;
	}
	.goods_name {
		display: block;
		font-size: 32rpx;
		color: $font-color-dark;
		line-height: 45rpx;
		height: 90rpx;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
	}
	
</style>
